package com.zy.news.controller;

import com.zy.news.entity.NewsComment;
import com.zy.news.mapper.NewsCommentMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "评论管理")
@RestController
@RequestMapping("comment")
public class NewsCommentController {

    @Resource
    private NewsCommentMapper mapper;

    @ApiOperation(value = "查询点开的新闻的评论列表")
    @GetMapping
    public List<NewsComment> findAll(int newsId){
        return mapper.findNewsCommentList(newsId);
    }

    @ApiOperation(value = "发表评论")
    @PostMapping
    public int add(NewsComment comment){
        return mapper.insert(comment);
    }

    @ApiOperation(value = "删除评论")
    @DeleteMapping
    public int del(int id){
        return mapper.deleteById(id);
    }

}
